clear all

* global inpath = "..." // Insert location of folder containing the dataset here
global inpath = "C:\Users\A1010571\Dropbox (BI Norwegian Business School)\WORKfiles\AFGEWERKTE TEKSTEN\AANVAARD Exit_Voice paper\LSQ"

use "$inpath\LSQ Scandals dataset.dta" 
 
 
***************************************************
*** Coding of Dependent and Treatment variables ***
***************************************************

** Make dummies out of seven-point scales
* (FIGURE A.2 and A.3: Remove stars in lines 16, 23 and 47 for robustness check dropping answer "4" as equivalent to 'don't know')

foreach k in Other_Indep Other_List Other_Leave Other_Refuse Other_Point {
gen `k'_yn=0
replace `k'_yn=1 if `k'==5 | `k'==6 | `k'==7
* replace `k'_yn=. if `k'==4
replace `k'_yn=. if `k'==.
}

foreach k in Own_Switch Own_Indep Own_List Own_Leave Own_Achieve Own_Point Own_Branch {
gen `k'_yn=0
replace `k'_yn=1 if `k'==5 | `k'==6 | `k'==7
* replace `k'_yn=. if `k'==4
replace `k'_yn=. if `k'==.
}

** Specific strategy dependent variables (common to 'own' and 'other' party treatments)
gen BecomeIndep = Own_Indep
replace BecomeIndep = Other_Indep if random==2 | random==4 | random==6
label variable BecomeIndep "After Scandal: Become independent"

gen SetOwnList = Own_List
replace SetOwnList = Other_List if random==2 | random==4 | random==6
label variable SetOwnList "After Scandal: Set up own party"

gen LeavePolitics = Own_Leave
replace LeavePolitics = Other_Leave if random==2 | random==4 | random==6
label variable LeavePolitics "After Scandal: Leave Politics"

gen PointOthers = Own_Point
replace PointOthers = Other_Point if random==2 | random==4 | random==6
label variable PointOthers "After Scandal: Point out scandals elsewhere"

foreach k in BecomeIndep SetOwnList LeavePolitics PointOthers {
gen `k'_yn=0
replace `k'_yn=1 if `k'==5 | `k'==6 | `k'==7
* replace `k'_yn=. if `k'==4
replace `k'_yn=. if `k'==.
}


** Treatment variables

* Type of scandal

gen Treatment=1 if random==1 | random==2
replace Treatment=2 if random==3 | random==4
replace Treatment=3 if random==5 | random==6
label define Treatment 1 "Unspecified" 2 "Financial" 3 "Sex"
label values Treatment Treatment
label variable Treatment "Scandal types"

gen Generic=1 if random==1 | random==2
replace Generic=0 if random==3 | random==4 | random==5 | random==6
label variable Generic "Dummy 1 if unspecified scandal"

gen Expense=1 if random==3 | random==4
replace Expense=0 if random==1 | random==2 | random==5 | random==6
label variable Expense "Dummy 1 if financial scandal"

gen Metoo=1 if random==5 | random==6
replace Metoo=0 if random==1 | random==2 | random==3 | random==4
label variable Metoo "Dummy 1 if sex scandal"

* Own versus other party

gen OwnParty=1 if random==1 | random==3 | random==5
replace OwnParty=0 if random==2 | random==4 | random==6
label variable OwnParty "Dummy 1 if scandal in OWN party"
label define OwnParty 1 "Own party" 0 "Other party"
label values OwnParty OwnParty

* National versus local party (not really a 'treatment'!!)

gen NatParty = NatParty_own
replace NatParty = NatParty_other if random==2 | random==4 | random==6
label variable NatParty "Effect national scandal on image national party"

gen LocParty = LocParty_own
replace LocParty = LocParty_other if random==2 | random==4 | random==6
label variable LocParty "Effect national scandal on image local party (branch)"


* Estimate of share of non-response to scandal
egen temp = rowmean(BecomeIndep_yn SetOwnList_yn LeavePolitics_yn PointOthers_yn Own_Branch_yn Own_Achieve_yn Own_Switch_yn) if OwnParty==1
egen temp2 = rowmean(BecomeIndep_yn SetOwnList_yn LeavePolitics_yn PointOthers_yn Other_Refuse_yn) if OwnParty==0
gen NoSupport_own = 1 if temp==0
replace NoSupport_own = 0 if temp>0 & temp~=.
gen NoSupport_other = 1 if temp2==0
replace NoSupport_other = 0 if temp2>0 & temp2~=.
fre NoSupport_own NoSupport_other if Indep==0
drop temp temp2

logit NoSupport_own Male i.Treatment Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
logit NoSupport_other Male i.Treatment Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.


** Additional controls

gen England = Region
replace England = 0 if Region~=1
replace England = . if Region==.

alpha GroupID*
pca GroupID*
rotate
predict GROUPID

save "$inpath\Data_for_graphs.dta", replace

***************************************************
****************** ANALYSIS ***********************
***************************************************
** NOTE: ALWAYS remove Independents and people without gender!! (i.e. Indep==0 & Male!=.)

* TABLE 2: Summary statistics
summ Male Age Uni Executive Terms England Con Lab LibDem if Indep==0

* ADDITIONAL Summary statistics of groups.
bysort OwnParty: summ Generic Expense Metoo if Indep==0


* FIGURE 2: Frequencies and Chi-2 tests by Own/Other party (and gender)

foreach k in BecomeIndep_yn SetOwnList_yn LeavePolitics_yn PointOthers_yn {
tab `k' OwnParty if Indep==0 & Male!=., cchi2 chi2 lrchi2 V
tab `k' OwnParty if Indep==0 & Male==1, cchi2 chi2 lrchi2 V
tab `k' OwnParty if Indep==0 & Male==0, cchi2 chi2 lrchi2 V
}
do "$inpath\Figure2.do" 


* FIGURE 3: Frequencies and Chi-2 tests by scandal type (and gender)

foreach k in BecomeIndep_yn SetOwnList_yn LeavePolitics_yn PointOthers_yn {
tab `k' Treatment if Indep==0 & Male!=., cchi2 chi2 lrchi2 V
tab `k' Treatment if Indep==0 & Male==1, cchi2 chi2 lrchi2 V
tab `k' Treatment if Indep==0 & Male==0, cchi2 chi2 lrchi2 V
}
do "$inpath\Figure3.do" 


* FIGURE A.3: Frequency additional answer options: Other_Refuse_yn, Own_Branch_yn, Own_Achieve_yn, Own_Switch_yn.
bysort Treatment: summ Other_Refuse_yn Own_Branch_yn Own_Achieve_yn Own_Switch_yn if Indep==0 & Male!=.


foreach k in Other_Refuse_yn Own_Branch_yn Own_Achieve_yn Own_Switch_yn {
tab `k' Treatment if Indep==0 & Male!=., cchi2 chi2 lrchi2 V
tab `k' Treatment if Indep==0 & Male==1, cchi2 chi2 lrchi2 V
tab `k' Treatment if Indep==0 & Male==0, cchi2 chi2 lrchi2 V
}

*********************************************
************* ROBUSTNESS CHECKS *************
*********************************************

* Table A.2a: Logit models own/other
logit BecomeIndep_yn OwnParty Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Ownother_Logit.doc, replace nocon keep(OwnParty) ctitle(Independent) e(chi2)
logit SetOwnList_yn OwnParty Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Ownother_Logit.doc, append nocon keep(OwnParty) ctitle(Own Party) e(chi2) 
logit LeavePolitics_yn OwnParty Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Ownother_Logit.doc, append nocon keep(OwnParty) ctitle(Leave Politics) e(chi2)
logit PointOthers_yn OwnParty Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Ownother_Logit.doc, append nocon keep(OwnParty) ctitle(Point to others) e(chi2) 


* Table A.2b: Ordered logit using full range of survey answer scale rather than dummy
ologit BecomeIndep OwnParty Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Ownother_OLogit.doc, replace nocon keep(OwnParty) ctitle(Independent) e(chi2)
ologit SetOwnList OwnParty Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Ownother_OLogit.doc, append nocon keep(OwnParty) ctitle(Own Party) e(chi2) 
ologit LeavePolitics OwnParty Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Ownother_OLogit.doc, append nocon keep(OwnParty) ctitle(Leave Politics) e(chi2)
ologit PointOthers OwnParty Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Ownother_OLogit.doc, append nocon keep(OwnParty) ctitle(Point to others) e(chi2) 


* Tables A.3a and A.4a: Logit models scandal type
logit BecomeIndep_yn i.Treatment Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Treatment_Logit.doc, replace nocon keep(i.Treatment) ctitle(Independent) e(chi2)
logit SetOwnList_yn i.Treatment Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Treatment_Logit.doc, append nocon keep(i.Treatment) ctitle(Own Party) e(chi2) 
logit LeavePolitics_yn i.Treatment Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Treatment_Logit.doc, append nocon keep(i.Treatment) ctitle(Leave Politics) e(chi2)
logit PointOthers_yn i.Treatment Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Treatment_Logit.doc, append nocon keep(i.Treatment) ctitle(Point to others) e(chi2) 
logit Own_Branch_yn i.Treatment Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Treatment_Logit.doc, append nocon keep(i.Treatment) ctitle(Own branch) e(chi2)
logit Own_Achieve_yn i.Treatment Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Treatment_Logit.doc, append nocon keep(i.Treatment) ctitle(Achievements) e(chi2) 
logit Own_Switch_yn i.Treatment Male Age Uni Terms Con Lab LibDem if Indep==0 & Male!=.
outreg2 using Treatment_Logit.doc, append nocon keep(i.Treatment) ctitle(Switch party) e(chi2)
logit Other_Refuse_yn i.Treatment Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Treatment_Logit.doc, append nocon keep(i.Treatment) ctitle(Refuse coop.) e(chi2) 


* Tables A.3b and A.4b: Ordered logit using full range of survey answer scale rather than dummy (by scandal type)
ologit BecomeIndep i.Treatment Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Treatment_OLogit.doc, replace nocon keep(i.Treatment) ctitle(Independent) e(chi2)
ologit SetOwnList i.Treatment Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Treatment_OLogit.doc, append nocon keep(i.Treatment) ctitle(Own Party) e(chi2) 
ologit LeavePolitics i.Treatment Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Treatment_OLogit.doc, append nocon keep(i.Treatment) ctitle(Leave Politics) e(chi2)
ologit PointOthers i.Treatment Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Treatment_OLogit.doc, append nocon keep(i.Treatment) ctitle(Point to others) e(chi2) 
ologit Own_Branch_yn i.Treatment Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Treatment_OLogit.doc, append nocon keep(i.Treatment) ctitle(Own branch) e(chi2)
ologit Own_Achieve_yn i.Treatment Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Treatment_OLogit.doc, append nocon keep(i.Treatment) ctitle(Achievements) e(chi2) 
ologit Own_Switch_yn i.Treatment Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Treatment_OLogit.doc, append nocon keep(i.Treatment) ctitle(Switch party) e(chi2)
ologit Other_Refuse_yn i.Treatment Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Treatment_OLogit.doc, append nocon keep(i.Treatment) ctitle(Refuse coop.) e(chi2) 


* Excluding respondents in leadership positions

* Own/Other party (cf. Fig2)

foreach k in BecomeIndep_yn SetOwnList_yn LeavePolitics_yn PointOthers_yn {
tab `k' OwnParty if Indep==0 & Male!=. & Position==4, cchi2 chi2 lrchi2 V
tab `k' OwnParty if Indep==0 & Male==1 & Position==4, cchi2 chi2 lrchi2 V
tab `k' OwnParty if Indep==0 & Male==0 & Position==4, cchi2 chi2 lrchi2 V
}

* Scandal type (cf. Fig3)

foreach k in BecomeIndep_yn SetOwnList_yn LeavePolitics_yn PointOthers_yn {
tab `k' Treatment if Indep==0 & Male!=. & Position==4, cchi2 chi2 lrchi2 V
tab `k' Treatment if Indep==0 & Male==1 & Position==4, cchi2 chi2 lrchi2 V
tab `k' Treatment if Indep==0 & Male==0 & Position==4, cchi2 chi2 lrchi2 V
}


* Two-way interactions Table A.2 

logit BecomeIndep_yn OwnParty##Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using OwnOther_Gender.doc, replace nocon ctitle(Independent) e(chi2)
logit SetOwnList_yn OwnParty##Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using OwnOther_Gender.doc, append nocon ctitle(Own Party) e(chi2) 
logit LeavePolitics_yn OwnParty##Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using OwnOther_Gender.doc, append nocon ctitle(Leave Politics) e(chi2)
logit PointOthers_yn OwnParty##Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using OwnOther_Gender.doc, append nocon ctitle(Point to others) e(chi2) 
ologit BecomeIndep OwnParty##Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using OwnOther_Gender.doc, append nocon ctitle(Independent) e(chi2)
ologit SetOwnList OwnParty##Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using OwnOther_Gender.doc, append nocon ctitle(Own Party) e(chi2) 
ologit LeavePolitics OwnParty##Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using OwnOther_Gender.doc, append nocon ctitle(Leave Politics) e(chi2)
ologit PointOthers OwnParty##Male Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using OwnOther_Gender.doc, append nocon ctitle(Point to others) e(chi2) 


* Two-way interactions Table A.3 and A.4
logit BecomeIndep_yn Male##i.Treatment Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Types_Gender.doc, replace nocon ctitle(Independent) e(chi2)
logit SetOwnList_yn Male##i.Treatment Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Types_Gender.doc, append nocon ctitle(Own Party) e(chi2) 
logit LeavePolitics_yn Male##i.Treatment Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Types_Gender.doc, append nocon ctitle(Leave Politics) e(chi2)
logit PointOthers_yn Male##i.Treatment Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Types_Gender.doc, append nocon ctitle(Point to others) e(chi2) 
ologit BecomeIndep Male##i.Treatment Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Types_Gender.doc, append nocon ctitle(Independent) e(chi2)
ologit SetOwnList Male##i.Treatment Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Types_Gender.doc, append nocon ctitle(Own Party) e(chi2) 
ologit LeavePolitics Male##i.Treatment Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Types_Gender.doc, append nocon ctitle(Leave Politics) e(chi2)
ologit PointOthers Male##i.Treatment Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Types_Gender.doc, append nocon ctitle(Point to others) e(chi2) 


logit Own_Branch_yn Male##i.Treatment Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Types_Gender2.doc, replace nocon ctitle(Own branch) e(chi2)
logit Own_Achieve_yn Male##i.Treatment Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Types_Gender2.doc, append nocon ctitle(Achievements) e(chi2) 
logit Own_Switch_yn Male##i.Treatment Age Uni Terms Con Lab LibDem if Indep==0 & Male!=.
outreg2 using Types_Gender2.doc, append nocon ctitle(Switch party) e(chi2)
logit Other_Refuse_yn Male##i.Treatment Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Types_Gender2.doc, append nocon ctitle(Refuse coop.) e(chi2) 
ologit Own_Branch Male##i.Treatment Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Types_Gender2.doc, append nocon ctitle(Own branch) e(chi2)
ologit Own_Achieve Male##i.Treatment Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Types_Gender2.doc, append nocon ctitle(Achievements) e(chi2) 
ologit Own_Switch Male##i.Treatment Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Types_Gender2.doc, append nocon ctitle(Switch party) e(chi2)
ologit Other_Refuse Male##i.Treatment Age Uni Executive Terms Con Lab LibDem i.PopSize if Indep==0 & Male!=.
outreg2 using Types_Gender2.doc, append nocon ctitle(Refuse coop.) e(chi2) 


* Three-way interactions 

logit BecomeIndep_yn OwnParty#Male#i.Treatment if Indep==0 & Male!=.
outreg2 using Threeway_logit.doc, replace nocon ctitle(Independent) e(chi2)
logit SetOwnList_yn OwnParty#Male#i.Treatment if Indep==0 & Male!=.
outreg2 using Threeway_logit.doc, append nocon ctitle(Own Party) e(chi2) 
logit LeavePolitics_yn OwnParty#Male#i.Treatment if Indep==0 & Male!=.
outreg2 using Threeway_logit.doc, append nocon ctitle(Leave Politics) e(chi2)
logit PointOthers_yn OwnParty#Male#i.Treatment if Indep==0 & Male!=.
outreg2 using Threeway_logit.doc, append nocon ctitle(Point to others) e(chi2) 

ologit BecomeIndep OwnParty#Male#i.Treatment if Indep==0 & Male!=.
outreg2 using Threeway_ologit.doc, replace nocon ctitle(Independent) e(chi2)
ologit SetOwnList OwnParty#Male#i.Treatment if Indep==0 & Male!=.
outreg2 using Threeway_ologit.doc, append nocon ctitle(Own Party) e(chi2) 
ologit LeavePolitics OwnParty#Male#i.Treatment if Indep==0 & Male!=.
outreg2 using Threeway_ologit.doc, append nocon ctitle(Leave Politics) e(chi2)
ologit PointOthers OwnParty#Male#i.Treatment if Indep==0 & Male!=.
outreg2 using Threeway_ologit.doc, append nocon ctitle(Point to others) e(chi2) 


* Alternative check for random assignment accross treatments
mlogit random Age Male Uni Executive Terms England Con Lab LibDem if Indep==0 & Male!=.

